<!--
 * @Description: 校验提示框
 * @Author: James324
 * @Date: 2023-09-26 17:35:21
 * @LastEditors: James324
 * @LastEditTime: 2024-01-27 16:11:12
-->
<script setup lang="ts">
type Position = 'left' | 'center';

defineProps({
    popoverVisible: {
        type: Boolean,
        default: false
    },
    popoverErrMsg: {
        type: String,
        default: '校验失败！'
    },
    // 箭头指针方向位置
    position: {
        type: String as PropType<Position>,
        default: 'left'
    }
});
</script>

<template>
    <Transition name="fade-top">
        <div v-if="popoverVisible" class="m-popover">
            <div :class="['m-popover__main', { 'm-popover__main--left': position === 'left' }]">
                <p>
                    {{ popoverErrMsg }}
                </p>
            </div>
        </div>
    </Transition>
</template>

<style lang="scss" scoped>
@include b(m-popover) {
    position: fixed;
    z-index: 1000;

    @include e(main) {
        position: relative;
        padding: 6px 15px;
        font-size: 14px;
        background: #595959;
        border-radius: 4px;
        box-shadow: 0 0 8px var(--q-color-shadow-primary);

        p {
            display: flex;
            align-items: center;
            margin: 0;
            line-height: 24px;

            &:first-child {
                color: #fff;
            }

            &:last-child {
                color: #fff;
            }
        }

        &::after {
            position: absolute;
            bottom: -6px;
            left: 50%;
            display: block;
            width: 0;
            height: 0;
            content: '';
            border-top: 6px solid #595959;
            border-right: 6px solid transparent;
            border-left: 6px solid transparent;
            transform: (translateX(-50%));
        }

        @include m(left) {
            &::after {
                left: 20%;
            }
        }
    }
}
</style>
